package AdapterAndFacade.Adapters;

import java.util.Enumeration;
import java.util.Iterator;

/**
 * 将迭代器适配成枚举
 * @Author: pengzx
 * @Description:
 * @Date: 14:49 2017/9/14
 * @Modified by: 1.0
 */
public class IteratorEnumeration implements Enumeration {
    Iterator iterator;
    @Override
    public boolean hasMoreElements()
    {
        return iterator.hasNext();
    }

    @Override
    public Object nextElement()
    {
        return iterator.next();
    }

    public IteratorEnumeration(Iterator iterator)
    {
        this.iterator = iterator;
    }
}
